<?php
require_once ROOT_ADMIN_MODELS.DS.'Models_Base.php';
class Models_Comment extends Models_Base{		    
    public function __construct(){
    	parent::__construct();
    	$this->_key="id";
    	$this->_table="comment";
       // $this->db=Zend_Registry::get('db');
    }
    
    public function listComment($from,$to)
    {
       	 $sql="SELECT 
       	 			`comment`.id id,`comment`.content content,`comment`.commentDate date,`comment`.email email,`comment`.username user,`comment`.`status` status,typenews.`name`,news.`headLines`,forum.`name` forum
				FROM 
					news,`comment`,typenews,forum
				WHERE
 					`comment`.news_id=news.id and news.typeNews_id=typenews.id and forum.id = typenews.forum_id ";
       	if($from != "")
       		$sql .= " AND commentDate >='$from' ";
       	if($to != "")
       		$sql .= " AND commentDate <='$to' ";
       	$sql .= "
 				ORDER BY
       	 			`comment`.commentDate DESC";
        $data=$this->_db->fetchAll($sql,null,Zend_Db::FETCH_OBJ);
        return $data;
    }
    
    public function active($id,$status)
    {
    	$sql="	UPDATE
    				`comment`
    			SET
    				status=$status
    			WHERE
    				id=$id";
    	$this->_db->query($sql);
    }   
}
	